package com.qidianit.mes.pro.controller;

import com.github.pagehelper.PageInfo;
import com.qidianit.mes.pojo.Result;
import com.qidianit.mes.pojo.pro.Process;
import com.qidianit.mes.pojo.pro.Workflow;
import com.qidianit.mes.pro.service.ProcessService;
import com.qidianit.mes.pro.service.WorkflowService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description:
 * @Author: wang fei long
 * @Date: 2025/9/17 0017 - 16:16
 */
@RestController
@RequestMapping("/workflow")
@CrossOrigin
public class WorkflowController {
    @Autowired
    private WorkflowService workflowService;
    @GetMapping("/page")
    public Result<PageInfo<Workflow>> selectList(Workflow workflow,
                                                 @RequestParam(defaultValue = "1") int page ,
                                                 @RequestParam(defaultValue = "10") int size){
        return workflowService.selectList(workflow,page,size);
    }
    @GetMapping("/code/{code}")
    public Result<Workflow> selectByWorkflowCode(@PathVariable String code){
        return workflowService.selectByWorkflowCode(code);
    }
    @PostMapping("/add")
    public Result insertWorkflow(@RequestBody Workflow workflow){
        return workflowService.insertWorkflow(workflow);
    }
    @PutMapping("/update")
    public Result updateById(@RequestBody Workflow workflow){
        return workflowService.updateById(workflow);
    }
    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable Long id){
        return workflowService.deleteById(id);
    }
    @DeleteMapping("/batchDelete")
    public Result batchDelete(Long[] id){
        return workflowService.batchDelete(id);
    }

}
